'use strict'

 const { DataTypes, Model, Op } = require('../../../azeroth').sequelize;
 class Sheet_2 extends Model { }

  const initSheetData_2 = (sequelize_aim) => {
    Sheet_2.init(
         {
            uid: {
                autoIncrement: true,
                type: DataTypes.INTEGER,
                allowNull: false,
                primaryKey: true
              },
              job_id: {
                type: DataTypes.INTEGER,
                allowNull: false,
                defaultValue: 0,
                primaryKey: true
              },
              sheet_id_seq: {
                type: DataTypes.INTEGER,
                allowNull: true
              },
              flaw_count: {
                type: DataTypes.INTEGER,
                allowNull: true
              },
              head_md: {
                type: DataTypes.DOUBLE(64,2),
                allowNull: true
              },
              length_md: {
                type: DataTypes.DOUBLE(64,2),
                allowNull: true
              },
              length_cd: {
                type: DataTypes.DOUBLE(64,2),
                allowNull: true
              },
              gen_time: {
                type: DataTypes.BIGINT,
                allowNull: true
              },
              gen_time_str: {
                type: DataTypes.STRING(64),
                allowNull: true
              },
              create_time: {
                type: DataTypes.STRING,
                allowNull: false
              }
         }, 
         {
             freezeTableName: true,
             sequelize: sequelize_aim,
             modelName: 'sheet',
             timestamps: false
         }
     )
  }

  Sheet_2.upload = async (data) => {
     let res = await Sheet_2.bulkCreate([data], {updateOnDuplicate: ['uid']});
     return res;
 }

 module.exports = {
     Sheet_2,
     initSheetData_2
 };